xquery version "1.0";
<results>
{
	for $b1 in doc("book_p1.xml")/catalog/book,
		$b2 in doc("book_p2.xml")/catalog/book
	where $b2/genre = $b1/genre
	return
		<book-compared>
			<title_p1 price="{$b1/price}">{$b1/title/text()}</title_p1>
			<title_p2 price="{$b2/price}">{$b2/title/text()}</title_p2>
		</book-compared>
}
</results>